<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Meteocal - Update Profile</title>
    </h:head>
    <h:body>
        <h:form id="form">
            <p:growl id="msgs" showDetail="true" />
            <p:panel header="Update Profile Form"> 
                    
                <h:panelGrid columns="3" id="regGrid">
                   
                    <h:outputLabel for="name">Name:</h:outputLabel>

                    <p:inputText id="name" value="#{userBean.name}" placeholder="#{userBean.name}" required="false" >
                      <p:ajax update="namemsg"/>
                    </p:inputText>
                    <p:message id="namemsg" for="name" />
                    
                    <h:outputLabel for="surname">Surname:</h:outputLabel>
                    
                    <p:inputText id="surname" value="#{userBean.userup.surname}"  placeholder="#{userBean.userup.surname}" required="false">
                    <p:ajax update="surnamemsg"/>
                    </p:inputText>
                    <p:message id="surnamemsg" for="surname" />

                    <p:outputLabel for="gender" value="Gender:" />
                    <p:selectOneRadio id="gender" value="#{userBean.userup.gender}"  required="false">
                        <f:selectItem itemLabel="Male" itemValue="Male" />
                        <f:selectItem itemLabel="Female" itemValue="Female" />
                    </p:selectOneRadio>
                    <p:message id="gendermsg" for="gender" />

                         <p:outputLabel for="DOB" value="DOB:" />
                      <p:calendar id="DOB" value="#{userBean.userup.dateOfBirth}" locale="de" navigator="true" pattern="dd-MMM-yyy">
                          <p:ajax event="dateSelect" listener="#{userBean.userup.onDateSelect}" update="msgs" />
                      </p:calendar>
 
                    <p:dialog modal="true" resizable="false" header="Your data" widgetVar="dlg" showEffect="fold">
                        <h:outputText value="User:" />
                        <h:outputText value="#{userBean.userup.dateOfBirth}">
                            <f:convertDateTime pattern="MM/dd/yyyy" />
                        </h:outputText>
                    </p:dialog>

                    
                    <h:outputLabel for="livignPlace">Living Place:</h:outputLabel>
                    <p:inputText id="livignPlace" value="#{userBean.userup.livignPlace}" placeholder="#{userBean.userup.livignPlace}" required="false">
                    <p:ajax update="livignPlacemsg"/>
                    </p:inputText>
                    <p:message id="livignPlacemsg" for="livignPlace" />
                    
                    
                    <p:outputLabel for="publicPrivate" value="Schedule:" />
                    <p:selectOneRadio id="publicPrivate" value="#{userBean.userup.idSchedule.public1}"  immediate="true" required="false">
                        <f:selectItem itemLabel="Public" itemValue="True" />
                        <f:selectItem itemLabel="Private" itemValue="False" />
                    </p:selectOneRadio>
                    <p:message id="publicPrivatemsg" for="publicPrivate" />
             
                </h:panelGrid>
                
                <p:commandButton value="Reset" type="reset" />
                <p:commandButton value="Update" actionListener="#{userBean.userup.click}" icon="ui-icon-check" />
                
                
                 <p:dialog modal="true" resizable="false" header="Values" widgetVar="dlg" showEffect="fold">
                    <p:panelGrid id="display" columns="2" columnClasses="label,value">

                        <h:outputText value="Name:" />
                        <h:outputText value="#{userBean.userup.name}">
                        </h:outputText>
                        <h:outputText value="Surname:" />
                        <h:outputText value="#{userBean.userup.surname}">
                        </h:outputText>
                        <h:outputText value="Gender:" />
                        <h:outputText value="#{userBean.userup.gender}">
                        </h:outputText>
                        <h:outputText value="DOB:" />
                        <h:outputText value="#{userBean.userup.dateOfBirth}">
                            <f:convertDateTime pattern="dd/MM/yyyy" />
                        </h:outputText>
                        <h:outputText value="Schedule:" />
                        <h:outputText value="#{userBean.userup.livignPlace}">
                        </h:outputText>
                        <h:outputText value="#{userBean.userup.idSchedule.public1}">
                        </h:outputText>
                        
                        <p:commandButton id="submit" value="Confirm" update="regGrid"
                                         action="#{userBean.update()}" />
                      
                    </p:panelGrid>
                </p:dialog>
                
                  
                                            

            </p:panel>
            
            
            
            <p:dialog modal="true" widgetVar="statusDialog" header="Please wait..."   
                          resizable="false" draggable="false" closable="false" showHeader="false">  
                    <center>
                        <h:outputText value="Loading, please wait..."/>
                        <br/>
                    </center>
                </p:dialog> 
            <p:panel>
                    <p:fieldset legend="Change Password">
                            
                            <p:panelGrid id="password" columns="3" style="border-color: inactiveborder">
     
                                
                                <h:outputText value="Old Password: "/>
                                <p:password id="pwdold" value="#{userBean.passwordControl}"  label="Old password" required="false"/>
                                <p:graphicImage url="#{userBean.icon()}" />                              
                               
                            </p:panelGrid>
                         <p:panelGrid columns="2">
                                <h:outputText value="New Password: "/>
                                <p:password id="pwd1" value="#{userBean.newPassword}" match="pwd2" label="New password" required="false"/>
                                <h:outputLabel for="pwd2">Confirm Password:</h:outputLabel>
                                <p:password id="pwd2" label="Confirm Password"/>
                                </p:panelGrid>
                            <p:commandButton value="Save new password" update="password" onclick="statusDialog.show();" actionListener="#{userBean.changePassword}" oncomplete="statusDialog.hide();"/>
                        </p:fieldset>
            </p:panel>
        </h:form>
    </h:body>
</html>

